/*
 * Copyright (C), 2014-2016, 杭州小卡科技有限公司
 * FileName: BalanceController.java
 * Author:   dommy
 * Date:     2016年3月18日 上午9:53:59
 * Description:
 */
package controller;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.ContextLoader;
import service.Service1;
import service.impl.Service1Impl;


@Controller
@RequestMapping("/1")
public class BbcBalanceController implements ApplicationContextAware {

	@Autowired
	private Service1 service1;

	private ApplicationContext applicationContext;

	@RequestMapping(value = "/testct")
	public @ResponseBody Entity balanceList() {
		System.out.println("111111111111111111111111111111111");
		Entity entity = new Entity();
		entity.setName("aaaaa");
		return entity;
	}


	@RequestMapping(value = "/testParentApplication")
	public void testParentApplication() {
		System.out.println("当前Controller所属容器---------------------------");
		System.out.println(applicationContext.getApplicationName()+":"+applicationContext.getDisplayName());
		System.out.println("service1---------------------------");
		service1.printApplicationName();

	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		this.applicationContext = applicationContext;
	}


	public static class Entity{
		private String name;

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}
	}

}
